package com.scpii.universal.pns.service;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.scpii.universal.hibernate.dao.BaseDao;
import com.scpii.universal.hibernate.intface.BaseInterface;
import com.scpii.universal.pns.hibernate.entity.UserPointRanks;

public class UserPointRanksService implements BaseInterface<UserPointRanks> {

	private BaseDao<UserPointRanks> userPointRanksDao;

	public void setUserPointRanksDao(BaseDao<UserPointRanks> userPointRanksDao) {
		this.userPointRanksDao = userPointRanksDao;
	}

	public UserPointRanks get(Long id) throws Exception {
		return userPointRanksDao.get(id);
	}

	@Override
	public UserPointRanks get(Integer id) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<UserPointRanks> getAll() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public UserPointRanks get(String propertyName, Object value)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<UserPointRanks> getList(String propertyName, Object value)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Long getTotalCount() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void save(UserPointRanks obj) throws Exception {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(UserPointRanks obj) throws Exception {
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(UserPointRanks obj) throws Exception {
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(Integer id) throws Exception {
		// TODO Auto-generated method stub

	}

	@Override
	public List<UserPointRanks> hqlGetList(String hql,
			Map<String, Object> argsMap) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void hqlUpdate(String namedHqlQuery, Map<String, Object> argsMap)
			throws Exception {
		// TODO Auto-generated method stub

	}

	@Override
	public Long hqlGetNums(String namedHqlQuery, Map<String, Object> argsMap)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<UserPointRanks> sqlGetList(String sqls,
			Map<String, Object> argsMap) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void sqlUpdate(String sqls, Map<String, Object> argsMap)
			throws Exception {
		// TODO Auto-generated method stub

	}

	@Override
	public Long sqlGetNum(String sqls, Map<String, Object> argsMap)
			throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	public String getRankNameByPoint(final Long uId) throws Exception {
		HibernateCallback<String> callback = new HibernateCallback<String>() {
			@Override
			public String doInHibernate(org.hibernate.Session session)
					throws HibernateException, SQLException {
				Query sqlQuery = session.getNamedQuery("SQL_RANK_POINTS");
				sqlQuery.setParameter("uid", String.valueOf(uId));
				String rankName = (String) sqlQuery.uniqueResult();
				return rankName;
			}
		};
		String result = userPointRanksDao.executeCallBack(callback);
		return result;
	}
}
